package com.ksyun.timeservice;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import static com.ksyun.timeservice.service.impl.TimeServiceImpl.register;
import static com.ksyun.timeservice.service.impl.TimeServiceImpl.unregister;

@SpringBootApplication
public class TimeServiceApplication {
    public static void main(String[] args) {
        //启动类
        SpringApplication.run(TimeServiceApplication.class,args);
        //启动的时候将信息注册到服务中心
        try {
            register();
        }catch (Exception e){
        }
        // 添加关闭钩子
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            // 程序结束，发送结束的消息
            try{
                unregister();
            }catch (Exception e){

            }
        }));
    }
}
